<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>table</title>
    <script>
        function del(){
            var pnde = document.getElementById("id1").parentNode;
            console.log(pnde);
            pnde.removeChild(id1);
        }
        function add(){
            var pnode = document.getElementsByTagName("table");
            var td1_str = document.createTextNode("dff");
            var td2_str = document.createTextNode("123")
            var td1 = document.createElement("td");
            var td2 = document.createElement("td");
            td1.appendChild(td1_str);
            td2.appendChild(td2_str);
            var tr = document.createElement("tr");
            tr.appendChild(td1);
            tr.appendChild(td2);
            pnode[0].appendChild(tr);
        }
        function dele() {
           var arr =  document.getElementsByTagName("tr");
           console.log(arr)
           for(var i=0;i<arr.length;i++ ){
               arr[i].click = function(){
                   console.log(arr[i]);
                   arr[i].parentNode.removeChild();
               }
           }
        }
    </script>
</head>
<body>
<table>
<tr>
    <td>姓名</td>
    <td>学号</td>
</tr>
<tr>
    <td>aa</td>
    <td>123</td>
</tr>
<tr >
    <td>bb</td>
    <td>456</td>
</tr>
<tr >
    <td>cc</td>
    <td>789</td>
</tr>
<tr id="id1" >
    <td>dd</td>
    <td>852</td>
</tr>
</table>
<button onclick="dele()">delete</button>
<button onclick="add()">add</button>
</body>
</html>